<template>
  <div class="box">
    <table-search
      slot="searchbar"
      v-model="searchData"
      :columns="searchOptions"
      @search="handleSearch"
    >
      <template slot="button">
        <a-button
          @click="handleExport"
          icon="download"
          style="color: #606266"
          slot="button"
          type="link"
        >
          导出
        </a-button>
        <!-- <a-button @click="handleAdd" icon="plus" style="color:#606266" slot="button" type="link">
          添加
        </a-button> -->
      </template>
    </table-search>
    <div class="table-box">
      <a-table
        :columns="columns"
        :data-source="data"
        size="middle"
        :scroll="{ x: 640 }"
        :pagination="false"
      >
        <template slot="index" slot-scope="scope">{{ scope.key }}</template>
        <template slot-scope="scope" slot="action">
          <a-button
            style="color: #2a5ee3"
            type="link"
            @click="handleDetail(scope)"
            size="small"
          >
            收银机明细
          </a-button>
          <a-button
            style="color: #2a5ee3"
            type="link"
            @click="handleDetails(scope)"
            size="small"
          >
            详情
          </a-button>
        </template>
      </a-table>
      <div class="pagination-box">
        <a-pagination
          show-quick-jumper
          @change="handleChange"
          :show-total="(total) => `共 ${total} 条`"
          :defaultCurrent="pagination.current"
          :pageSize="pagination.pageSize"
          :total="pagination.total"
          :hideOnSinglePage="true"
        />
      </div>
    </div>
    <a-modal :visible="visible" width="400px">
      <template slot="title">
        <span>{{ title }}</span>
      </template>
      <template slot="closeIcon">
        <div style="width: 100%; height: 100%" @click="handleCancel">
          <a-icon type="close" />
        </div>
      </template>
      <template slot="footer">
        <div style="text-align: center">
          <a-button
            style="margin: 0 25px"
            key="back"
            type="danger"
            ghost
            @click="handleCancel"
          >
            取消
          </a-button>
          <a-button
            style="margin: 0 25px"
            key="submit"
            type="primary"
            :loading="confirmLoading"
            @click="handleEduce"
          >
            导出
          </a-button>
        </div>
      </template>
      <a-table
        :columns="modalColumns"
        :data-source="modalData"
        size="middle"
        :scroll="{ x: 250 }"
        :pagination="false"
      >
        <template slot="index" slot-scope="scope">{{ scope.key }}</template>
      </a-table>
    </a-modal>
  </div>
</template>

<script>
import columns from "./colums";
import modalColumns from "./modalColumns";
export default {
  data() {
    return {
      title: "",
      visible: false,
      confirmLoading: false,
      columns,
      modalColumns,
      modalData: [
        {
          key: "1",
          classification: "其他",
          turnover: "￥23472.11",
        },
      ],
      data: [
        {
          key: "1",
          supermarketName: "孙武三泽购物广场",
          mechanism: "孙武街道",
          orderNum: "1107",
          cashNum: "22762.74",
        },
        {
          key: "2",
          supermarketName: "孙武三泽购物广场",
          mechanism: "孙武街道",
          orderNum: "1107",
          cashNum: "22762.74",
        },
      ],
      pagination: {
        total: 50,
        current: 1,
        pageSize: 10,
      },
      searchData: {},
      searchOptions: [
        {
          type: "daterange",
          label: "日期",
          prop: "taxationss",
        },
        {
          type: "select",
          label: "超市名称",
          prop: "taxations",
          attrs: {
            filterable: true,
          },
          enums: [
            {
              label: "孙武三泽购物广场",
              value: "1",
            },
          ],
        },
        {
          type: "select",
          label: "所属机构",
          prop: "taxation",
          attrs: {
            filterable: true,
          },
          enums: [
            {
              label: "孙武街道",
              value: "1",
            },
          ],
        },
      ],
    };
  },
  methods: {
    handleSearch(val) {
      console.log(val, "查询");
    },
    // handleEdit(val) {
    //   console.log(val,'编辑')
    // },
    // handleDelete(val) {
    //   console.log(val,'删除')
    // },
    handleDetail(val) {
      console.log(val, "明细");
      const info = encodeURIComponent(JSON.stringify(val));
      this.$router.push({
        path: "/stat/supermarket/detail",
        query: { site: info },
      });
    },
    handleDetails(val) {
      console.log(val, "详情");
      this.title = val.supermarketName;
      this.visible = true;
    },
    handleChange(page, pageSize) {
      console.log(page, pageSize, "分页");
    },
    handleExport() {
      console.log("导出");
    },
    // handleAdd() {
    //   console.log('添加')
    // }
    handleCancel() {
      //取消
      this.visible = false;
    },
    handleEduce() {
      //弹出层导出
      this.visible = false;
    },
  },
};
</script>

<style lang="less" scoped>
.box {
  .table-box {
    padding-top: 30px;
  }
  .pagination-box {
    text-align: right;
    // position: absolute;
    // bottom: 40px;
    // right: 16px;
    padding-top: 40px;
    .ant-pagination {
      display: inline-block;
    }
  }
}
</style>
